package com.sz.lk.wingsystem.mvp.presenter;

import com.sz.lk.wingsystem.bean.ManualResult;
import com.sz.lk.wingsystem.bean.WeightResult;
import com.sz.lk.wingsystem.mvp.OnNetRequestListener;
import com.sz.lk.wingsystem.mvp.RxPresenter;
import com.sz.lk.wingsystem.mvp.contract.WeighContract;
import com.sz.lk.wingsystem.mvp.model.WeighModel;

/**
 * author : liuke
 * e-mail : 1012459343@qq.com
 * date   : 2020/12/6 17:19
 * desc   :
 * version: 1.0
 */
public class WeighPresenter extends RxPresenter<WeighContract.view> implements WeighContract.Presenter {
    private WeighContract.Model model = new WeighModel(this);

    @Override
    public void Get_WeighCartonNo(String weightStr) {
        //View是否绑定 如果没有绑定，就不执行网络请求
        if (!isViewAttached()) {
            return;
        }
        model.WeighCartonNo(weightStr, new OnNetRequestListener<WeightResult>() {
            @Override
            public void onStart() {
                mView.showLoading();
            }

            @Override
            public void onFinish() {
                mView.hideLoading();
            }

            @Override
            public void onSuccess(WeightResult data) {
                mView.onWeighCartonNoSuccess(data);
            }

            @Override
            public void onFailure(Throwable t) {

            }
        });
    }

    @Override
    public void Get_ManualNewReportInfo(String code, double weight, double volume, double length, double width, double height) {
        //View是否绑定 如果没有绑定，就不执行网络请求
        if (!isViewAttached()) {
            return;
        }
        model.ManualNewReportInfo(code, weight, volume, length, width, height, new OnNetRequestListener<ManualResult>() {
            @Override
            public void onStart() {
                mView.showLoading();
            }

            @Override
            public void onFinish() {
                mView.hideLoading();
            }

            @Override
            public void onSuccess(ManualResult data) {
                mView.onManualNewReportInfoSuccess(data);
            }

            @Override
            public void onFailure(Throwable t) {
                mView.onError(t);
            }
        });
    }
}